// 设置显示页面的中间件,用于显示左边侧边栏与右侧的具体页面

// 关闭VSCode非必要报错
// ignore_for_file: camel_case_types, prefer_const_constructors_in_immutables, non_constant_identifier_names, unused_element, unused_local_variable

import 'package:easy_sidemenu/easy_sidemenu.dart';
import 'package:flutter/material.dart';
import 'package:project_award_statistics/utils/my_side_menu/my_side_menu.dart';

class MiddlePage_Desktop extends StatefulWidget {
  // 获取必需的学生名字
  final String stu_name; 
  MiddlePage_Desktop({
    super.key,
    required this.stu_name,
  });

  @override
  State<MiddlePage_Desktop> createState() => _MiddlePage_DesktopState();
}

class _MiddlePage_DesktopState extends State<MiddlePage_Desktop> {
  @override
  Widget build(BuildContext context) {

    // 设置侧边栏所需的pageController与SideMenu类控制器
    PageController pageController=PageController();
    SideMenuController sideMenu=SideMenuController();

    // 从widget父类传入用户(学生)姓名
    String stu_name=widget.stu_name;
    // 覆写父类构造函数
  @override
  void initState ()
    {
      // 从父类传入当前学生姓名
      stu_name=widget.stu_name;
      // 覆写页面更新时行为
      sideMenu.addListener((index){
        pageController.jumpToPage(index);
      });
      super.initState();
    }

    return Scaffold(
      backgroundColor: Colors.white,
      body: Padding(
        padding: const EdgeInsets.only(top:15.0,left: 25.0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            MySideMenu_Desktop(
              pageController: pageController, 
              sideMenu: sideMenu,
              stu_name: widget.stu_name,
            ),
          ],
        ),
      ),
    );
  }
}
